<!--导航部分-->
<link rel="stylesheet" type="text/css" href="statics/css/nav.css" />
<div class="nav" style="position:relative;">
    <ul>
        <li>
            <label><i></i>小说馆</label>
        </li>
        <li>
            <a id="home" href="/" >首页</a>
        </li>
        <li>
            <a id="phb" href="/phb.php">人气榜</a>
        </li>
        <li>
            <a id="my" href="/my.php">我的</a>
        </li>
        <?php

        //验证session
        session_start();
        if(!isset($_SESSION['username'])){
            echo '
                <li>
                    <a href="javascript:user_login()">登录</a>
                </li>
            ';
        }
        ?>
        <li>
            <style>
                .search_btn:hover{
                    cursor: pointer;
                    color:red;
                }
            </style>
           <div style="line-height: 48px;height: 48px;">
                <input id="name" style="font-size:30px;margin-top: 4px;" maxlength="16" type="text" placeholder="搜索小说" autocomplete="off" disableautocomplete />
                <div onclick="search()" class="search_btn"   style="font-size:24px;background-color: green;width: 100px;height:40px;line-height: 40px;margin-top: 4px;text-align: center;padding-left:0;    margin-left: 5px;float: left;">
                    提交
                </div>
            </div>
           <script>
               //弹出登录框
               function user_login(){
                   $(".login_shadow").css("display","block");
               }
               //关闭弹窗
               function close_login(){
                $(".login_shadow").css("display","none");
               }
               //登出
               function logout(){
                $.post(
                        "controler.php",
                        {
                            handle:"logout",
                        },
                        function(msg){
                            if(msg=="done"){
                                location.href="/my.php";
                            }
                            else{
                                alert("系统出错");
                            }
                        }
                    )
               }
               //查找
               function search(){
                   if($("#name").val()==""){
                       alert("请输入小说名");
                       return false;
                   }
                   
                   $.post(
                        "controler.php",
                        {
                            handle:"get",
                            name:$("#name").val(),
                        },
                        function(msg){
                            if(msg.split("||")[1]=="done"){
                                location.href="novel.php?name="+msg.split("||")[0];
                            }
                            else if(msg.split("||")[1]=="no"){
                                alert("没有找到该小说");
                            }
                            else{
                                alert("系统出错");
                            }
                        }
                    )

               }
               
           </script>
        </li>
    </ul>
</div>
<!--导航结束-->
<?php
    include("login.php");
?>